<?
include("config.php");

$s = mssql_query("DROP VIEW VLatestKarir");
if($s){
	$q = mssql_query("Create View VLatestKarir as WITH AX AS (SELECT MAX(seqno) AS nilai, NIK FROM KarirPTSI GROUP BY NIK) SELECT A.NIK, C.Nama, C.Alamat, C.TempatLahir, C.Status AS Marital, C.Tgl_Lahir, C.JKel, C.Agama, C.id_kar, B.tgl_efektif, B.kode_so1, B.kode_so2, B.gol1, B.gol2, B.no_surat, B.Jenis, B.stat_kar1, B.stat_kar2, B.jabatan1, B.jabatan2, B.fungsi1, B.fungsi2 FROM AX AS A INNER JOIN KarirPTSI AS B ON A.NIK = B.NIK AND A.nilai = B.seqno INNER JOIN Karyawan AS C ON A.NIK = C.NIK");
	if($q){
		echo"Update View OK, Thank You";
	}

}					  
?>